ZF.add('native-function', function(Z) {

    Z.Function = {

        create : function(fn, options){
            options = options || {};
            return function(event){
                var args = options.arguments, slice = Array.prototype.slice;

                args = (args != undefined) ? slice.call(args, 0) : slice.call(arguments, (options.event) ? 1 : 0);
                
                if (options.event) {
                    args = [event || window.event].concat(args);
                }

                var returns = function(){
                    return fn.apply(options.bind || null, args);
                };

                if (options.delay) {
                    return setTimeout(returns, options.delay);
                }

                if (options.periodical) {
                    return setInterval(returns, options.periodical);
                }

                return returns();
            };
        },

        bind: function(fn, bind, args){
            return this.create(fn, { bind : bind, arguments : args });
        },

        bindWithEvent: function(fn, bind, args){
            return this.create(fn, { bind : bind, event : true, arguments : args });
        },

        delay: function(fn, delay, bind, args){
            return this.create(fn, { delay : delay, bind : bind, arguments : args })();
        },

        periodical: function(fn, interval, bind, args){
            return this.create(fn, { periodical : interval, bind : bind, arguments : args })();
        }

    };

});